//
// package com.hlkj.pay.listener;
// /*
//  * Hlpay-Plus aggregate payment system.
//  * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
//  */
//
// import java.time.Instant;
// import java.time.LocalDateTime;
// import java.time.ZoneId;
// import java.time.ZonedDateTime;
// import java.time.format.DateTimeFormatter;
// import java.util.concurrent.Executor;
//
// import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
// import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
// import org.apache.rocketmq.spring.core.RocketMQListener;
// import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
// import org.springframework.context.annotation.Bean;
// import org.springframework.scheduling.annotation.Async;
// import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
// import org.springframework.stereotype.Component;
//
// import com.hlkj.framework.common.util.json.JsonUtils;
// import com.hlkj.pay.app.ad.IAdPayOrderCallService;
// import com.hlkj.pay.common.constants.BaseConstants;
// import com.hlkj.pay.common.constants.MqConstant;
// import com.hlkj.pay.dto.ad.AdStatisticsDto;
//
// import lombok.extern.slf4j.Slf4j;
//
// /**
//  * @author HlpayTeam
//  * @date 2024/10/24 12:58
//  */
// @Slf4j
// @Component
// @ConditionalOnProperty(prefix = "rocketmq", name = "enabled", havingValue = "true")
// @RocketMQMessageListener(topic = MqConstant.AD_CALL_RECORD_TOPIC, consumerGroup = "ad_order_call")
// public class AdCallBackConsumer implements RocketMQListener<AdStatisticsDto>, RocketMQPushConsumerLifecycleListener {
//
//     @Autowired
//     private IAdPayOrderCallService adPayOrderCallService;
//
//     DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//
//     @Override
//     @Async("adOrderCallTaskExecutor")
//     public void onMessage(AdStatisticsDto adStatisticsDto) {
//         if (adStatisticsDto.getTime() == null) {
//             adStatisticsDto.setTime(System.currentTimeMillis());
//         }
//         LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(adStatisticsDto.getTime()), ZoneId.of(BaseConstants.shanghaiTimeZoneId));
//         log.info("收到回传消息 mq:{},sendTime:{},now:{}", JsonUtils.toJsonString(adStatisticsDto), dateTime.format(formatter),
//                 ZonedDateTime.now(ZoneId.of(BaseConstants.shanghaiTimeZoneId)).toLocalDateTime().format(formatter));
//         adPayOrderCallService.processCallMessage(adStatisticsDto);
//     }
//
//     @Override
//     public void prepareStart(DefaultMQPushConsumer consumer) {
//         // 设置当前实例的名称
//         consumer.setInstanceName(MqConstant.AD_CALL_RECORD_TOPIC);
//     }
//
//
// }
